package q9

import (
	"fmt"
	"strconv"
)

func isPalindrome(x int) bool {
	return isPalindromeByInt(x)
	return isPalindromeByStr(x)
}

func isPalindromeByStr(x int) bool {
	str := strconv.Itoa(x)

	i := 0
	j := len(str) - 1
	for i <= j {
		if str[i] != str[j] {
			return false
		}
		i++
		j--
	}

	return true
}

func isPalindromeByInt(x int) bool {
	if x < 0 {
		return false
	}

	var x0 = x
	var x1 = 0

	for x > 0 {
		x1 = x1*10 + x%10
		x = x / 10
		fmt.Println(x, x1)
	}
	return x0 == x1
}
